<template>
    <div>
        <el-form  :inline="true" :model="formInline" style="text-align: left;" class="demo-form-inline">
            <el-form-item label="搜索考试名称">
                <el-input v-model="formInline.user" placeholder="搜索考试名称"></el-input>
            </el-form-item>
            <el-form-item label="开放类型">
                <el-select v-model="formInline.region" placeholder="开放类型">
                    <el-option label="区域一" value="shanghai"></el-option>
                    <el-option label="区域二" value="beijing"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">查询</el-button>
            </el-form-item>
        </el-form>
        <div class="table-box">
        <el-table
            border
            :data="examTable"
            style="width: 100%;"
            :default-sort = "{prop: 'date', order: 'descending'}"
    >
        <el-table-column
                prop="name"
                label="考试名称"
                sortable
                >
        </el-table-column>
<!--        <el-table-column-->
<!--                prop="type"-->
<!--                label="考试类型"-->
<!--                sortable-->
<!--                >-->
<!--        </el-table-column>-->

        <el-table-column
                prop="startTime"
                label="考试时间"
                sortable
                >
            <template slot-scope="scope">
                {{scope.row.startTime|date}}
            </template>
        </el-table-column>
        <el-table-column
                prop="deadTime"
                label="考试时间"
                sortable
                >
            <template slot-scope="scope">
                {{scope.row.deadTime|date}}
            </template>
        </el-table-column>
        <el-table-column
                prop="duration"
                label="考试时长(分钟)"
                >
        </el-table-column>
        <el-table-column
                prop="paper.totalScore"
                label="考试总分"
               >
        </el-table-column>
        <el-table-column
                    prop="paper.passScore"
                    label="及格线"
                    >
        </el-table-column>
        <el-table-column label="操作" >
            <template slot-scope="scope">
            <el-button  size="mini"
                        type="primary"
                        style="display: table-cell;vertical-align: middle;"
                        @click="$router.push({name:'ReadyExam',params: scope.row})" >进入考试</el-button>
            </template>
        </el-table-column>

    </el-table>
        </div>
    </div>

</template>

<script>
    import {examList} from "../../request/api";

    export default {
        created() {
            examList().then(resp=>{
                console.log(resp.data.data);
                let {examList}=resp.data.data;
                this.examTable=examList
            })
        },
        data() {
            return {
                formInline: {
                    user: '',
                    region: ''
                },
                examTable:[],
                examTable: [
                    {
                        name:"JAVA基础",
                        // type:"计算机类",
                        startTime:new Date(),
                        duration:"50分钟",
                        totalScore:"100",
                        passLine:"60",

                    },{
                        name:"基础",
                        // type:"计算机类",
                        startTime:new Date(),
                        duration:"60分钟",
                        totalScore:"100",
                        passLine:"60",
                    },
                ]
            }
        },
        methods: {
            goExam(row){
                console.log(row);
            },
            onSubmit() {
                this.$message({
                    message: '此功能尚未开发',
                    type: 'success'
                });
            }
        }
    }
</script>
<style>
</style>